// pages/doctor/doctor.js
var app=getApp()
Page({
  data: {
    select: false,
    department: '医生科室',
    items: [
      { name: '儿科', value: '儿科' },
      { name: '内分泌科', value: '内分泌科' },
      { name: '骨科', value: '骨科' },
      { name: '外科', value: '外科' },
    ],
    depart:'',
  },
  onLoad: function (options) {
  },
  onShareAppMessage: function () {
  },
  radioChange: function (e) {
    console.log('radio发生change事件，携带value值为：', e.detail.value);
    this.setData({
      text: '您选择了' + e.detail.value + '科',
      depart:e.detail.value,
    })
    console.log("医生科室" + this.data.depart)
  },
  
  formSubmit: function (e) {
    var that =this;
    console.log('form发生了submit事件，携带数据为：', e.detail.value);
    var objDate = e.detail.value;
    if (objDate.doctorname&&objDate.age&&objDate.tel &&this.data.depart){
      wx.setStorage({
        key: 'doctorname',
        data: objDate.doctorname,
      })
      wx.setStorage({
        key: 'age',
        data: objDate.age,
      })
      wx.setStorage({
        key: 'tel',
        data: objDate.tel,
      })
      wx.setStorage({
        key: 'depart',
        data: this.data.depart,
      })
      wx.request({
        url: app.globalData.url + '/API/doctor',
        data: {
          'doctorname': e.detail.value.doctorname,
          'doctorage': e.detail.value.age,
          'doctortel': e.detail.value.tel,
          'doctordepartment':this.data.depart
        },
        method: 'get',
        header: {
          'content-type': 'application/json'
        }, 
        success: function (res) {
          console.log(res.data)
        }
      })
      wx.navigateTo({
        url: '../doctorhomepage/doctorhomepage',
      })
    }
  },
  
})

